from flask import Blueprint, jsonify, request
from app.services.weather_service import WeatherService
import requests
weather_bp = Blueprint('weather', __name__)

@weather_bp.route('/api/weather/getWeather', methods=['GET'])
def get_weather():
    """获取天气数据"""
    try:

        # 获取请求参数
        district_id = request.args.get('district_id', '420100')
        data_type = request.args.get('data_type', 'all')
        
        data = WeatherService.get_all_weather_data(district_id, data_type)

        return jsonify(data)
    except Exception as e:
        return jsonify({
            "success": False,
            "message": str(e)
        }), 500 